<template>
    <view>
        <uni-nav-bar leftIcon="back" @clickLeft="back" :statusBar="true" shadow  :fixed="true" :title="title" color="#101010" backgroundColor="#fff"></uni-nav-bar>
        <!-- 网格员端  一周巡查 -->
        <view class="viewBox" v-if="userInfo.roleCode == 'wgy'">
            <view class="sumbitList">
                <label><span>*</span>乡镇街道:</label>
                <input type="text" placeholder="请输入" v-model="street">
            </view>
            <view class="sumbitList">
                <label><span>*</span>教别:</label>
                <input type="text" placeholder="请输入" v-model="religion">
            </view>
            <view class="sumbitList">
                <label><span>*</span>场所名称:</label>
                <input type="text" placeholder="请输入" v-model="place">
            </view>
            <view class="sumbitList">
                <label><span>*</span>巡查时间:</label>
                <input :disabled="true" type="text" placeholder="请输入" v-model="checkTime" @click="show">
            </view>
            <view class="sumbitList">
                <label><span>*</span>巡查人员:</label>
                <input type="text" placeholder="请输入" v-model="checkPerson">
            </view>
            <p>1.四进一提醒是否规范</p>
            <radio-group @change="(e) => { normFlag = evt.detail.value }">
                <radio value="1" :checked="normFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="normFlag === 0" />否
            </radio-group>
            <p>2.是否有未成年人参加ZJ活动</p>
            <radio-group @change="(e) => { minorityFlag = evt.detail.value }">
                <radio value="1" :checked="minorityFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="minorityFlag === 0" />否
            </radio-group>
            <p>3.是否有ZJ类非法出版物</p>
            <radio-group @change="(e) => { illegalFlag = evt.detail.value }">
                <radio value="1" :checked="illegalFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="illegalFlag === 0" />否
            </radio-group>
            <p>4.是否发现其他问题</p>
            <radio-group @change="(e) => { otherFlag = evt.detail.value }">
                <radio value="1" :checked="otherFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="otherFlag === 0" />否
            </radio-group>
            <view class="sumbitList">
                <label>情况反馈:</label>
                <textarea type="text" v-model="feedback" placeholder="请输入具体反馈情况及详细地址"></textarea>
            </view>
            <tui-datetime :type="2" ref="dateTime" @confirm="change"></tui-datetime>
            <tui-button @click="weekAdd" class="btn" width="60%" height="80rpx" margin="auto" :size="28">确定</tui-button>
        </view>
        <!-- 各单位端  专项巡查-->
        <view class="viewBox" v-else-if="userInfo.roleCode == 'gdw'">
            <view class="sumbitList">
                <label><span>*</span>排查对象:</label>
                <input type="text" placeholder="请输入" v-model="place">
            </view>
            <view class="sumbitList">
                <label><span>*</span>排查时间:</label>
                <input :disabled="true" type="text" placeholder="请输入" v-model="checkTime" @click="show">
            </view>
            <view class="sumbitList">
                <label><span>*</span>排查人员:</label>
                <input type="text" placeholder="请输入" v-model="checkPerson">
            </view>
            <p>1.该场地是否存在涉及ZJ内容</p>
            <radio-group @change="(e) => { contentFlag = evt.detail.value }">
                <radio value="1" :checked="contentFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="contentFlag === 0" />否
            </radio-group>
            <p>2.该场地是否建造ZJ造像和大型ZJ标识</p>
            <radio-group @change="(e) => { statueFlag = evt.detail.value }">
                <radio value="1" :checked="statueFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="statueFlag === 0" />否
            </radio-group>
            <p>3.该场地具体负责人是否存在信教情况</p>
            <radio-group @change="(e) => { responsibleBelieveFlag = evt.detail.value }">
                <radio value="1" :checked="responsibleBelieveFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="responsibleBelieveFlag === 0" />否
            </radio-group>
            <p>4.该场地工作人员是否存在信教情况</p>
            <radio-group @change="(e) => { workerBelieveFlag = evt.detail.value }">
                <radio value="1" :checked="workerBelieveFlag === 1" />是<text class="left"></text>
                <radio value="0" :checked="workerBelieveFlag === 0" />否
            </radio-group>
            <tui-datetime :type="2" ref="dateTime" @confirm="change"></tui-datetime>
            <tui-button @click="addSpe" class="btn" width="60%" height="80rpx" margin="auto" :size="28">确定</tui-button>
        </view>
        <view v-else>未知</view>
    </view>
</template>

<script>
import {
    mapState,
    mapGetters,
    mapMutations
} from 'vuex'

export default {
    components: {},
    data() {
        return {
            title: '新增巡查',
            // 一周巡查
            "street": '', // "测试街道",
            "religion": '', // "教别",
            "normFlag": 1, // "1",
            "minorityFlag": 1, // "1",
            "illegalFlag": 1, // "1",
            "otherFlag": 1, // "1",
            "feedback": '', // '',//"情况反馈",

            // 专项巡查
            "checkTime": '', // "",
            "contentFlag": 1, // "1",
            "statueFlag": 1, // "1",
            "responsibleBelieveFlag": 1, // "1",
            "workerBelieveFlag": 1, // "1",
            // common
            place: '',//"场所名称",排查对象",
            checkPerson: '',//巡查
            checkTime: '', // "2023-08-24",

            type: 1,
        };
    },
    computed: {
        ...mapGetters(['tabBar', "hasLogin"]),
        ...mapState(["isUserPhone", 'userInfo']),
    },
    onLoad() {
        console.log(this.userInfo.roleCode);
        // if (this.userInfo.roleCode == 'wgy') this.title = '一周一巡查';
        // if (this.userInfo.roleCode == 'gdw') this.title = '专项巡查';
    },
    onReady: function (options) {
    },
    onUnload() {

    },
    onShow() {

    },
    methods: {
        back() {
				uni.navigateBack({
					delta: 1
				})
			},
        /** 一周巡查提交 */
        weekAdd() {
            if(this.street=='') return this.$api.msg('有选项未输入');
            if(this.religion=='') return this.$api.msg('有选项未输入');
            if(this.place=='') return this.$api.msg('有选项未输入');
            if(this.checkTime=='') return this.$api.msg('有选项未输入');
            if(this.checkPerson=='') return this.$api.msg('有选项未输入');
            this.$api.showLoading();
            this.$apis.weekCheckAdd({
                "street": this.street,
                "religion": this.religion,
                "place": this.place,
                "checkTime": this.checkTime,
                "checkPerson": this.checkPerson,
                "normFlag": this.normFlag,
                "minorityFlag": this.minorityFlag,
                "illegalFlag": this.illegalFlag,
                "otherFlag": this.otherFlag,
                "feedback": this.feedback
            }).then(res => {
                this.$api.hideLoading();
                this.$api.msg(res.message);
                uni.navigateBack({
                    delta: 1
                })
            })
        },
        /** 专项新增 */
        addSpe() {
            if(this.place=='') return this.$api.msg('有选项未输入');
            if(this.checkTime=='') return this.$api.msg('有选项未输入');
            if(this.checkPerson=='') return this.$api.msg('有选项未输入');
            this.$api.showLoading();
            this.$apis.specialCheckAdd({
                "place": this.place,
                "checkTime": this.checkTime,
                "checkPerson": this.checkPerson,
                "contentFlag": this.contentFlag,
                "statueFlag": this.statueFlag,
                "responsibleBelieveFlag": this.responsibleBelieveFlag,
                "workerBelieveFlag": this.workerBelieveFlag
            }).then(res => {
                this.$api.hideLoading();
                this.$api.msg(res.message);
                uni.navigateBack({
                    delta: 1
                })
            })
        },
        show: function (e) {
            this.$refs.dateTime && this.$refs.dateTime.show();
        },
        change: function (e) {
            //选择的结果
            this.checkTime = e.result;
        }
    }
}
</script>

<style lang="scss">
page {
    background: #fff;
}

.custom {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 11;
}

.left {
    margin-right: 4rem;
}

textarea {
    border: 1px solid #666;
    border-radius: 10rpx;
    padding: 20rpx;
    height: 6rem;
}

.sumbitList {
    display: flex;
    margin: 30rpx 0;
    align-items: center;

    label {
        width: 25%;
        font-size: 30rpx;

        span {
            color: red;
        }
    }

    input {
        width: 75%;
        height: 65rpx;
        padding: 0 30rpx;
        border-radius: 10rpx;
        border: 1px solid #999;
    }
}

.viewBox {
    padding: 20rpx;
    position: relative;
    height: 100%;

    p {
        margin: 40rpx 0;
    }
}
</style>